<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/

if(isset($_SESSION['u_nic'])&&isset($_GET['id'])) {
	$tpl->assign(array(
		'iconesleft' => 2,
		'prod' => '0',
		'prod_id' => intval($_GET['id'])
	));
	include('php/lib/panel_inc.php');
	$heberg_current = intval($_GET['id']);
	$infos_heberg = mysql_query("SELECT comptes_heberg.id,
										comptes_heberg.u_nic,
										comptes_heberg.uid_linux,
										comptes_heberg.user_linux,
										comptes_heberg.serveur_apache,
										comptes_heberg.offre,
										comptes_heberg.etat,
										comptes_heberg.doms  AS c_doms,
										offre_heberg.doms AS o_doms_,
										offre_surmesure.doms as o_doms
										FROM comptes_heberg 
										LEFT JOIN offre_heberg
										ON comptes_heberg.offre = offre_heberg.id_offre
										LEFT JOIN offre_surmesure
										ON comptes_heberg.id = offre_surmesure.id_heberg
										WHERE comptes_heberg.id='".$heberg_current."' AND comptes_heberg.u_nic='".$_SESSION['u_nic']."'")or die(mysql_error());
	if(mysql_num_rows($infos_heberg) == 1) {
		$infos_heberg = mysql_fetch_array($infos_heberg);
		if($infos_heberg['o_doms'] == "") {
			$infos_heberg['o_doms'] = $infos_heberg['o_doms_'];
		}
		$tpl->assign(array('etat' => $infos_heberg['etat']));
		if($infos_heberg['etat'] == 1) {
				$parse = 1;
				$title = "Gestion des domaines liés à l'hébergement";
				$tplinc = "panel-hebergement-doms";
				if($infos_heberg['o_doms'] == "") { $infos_heberg['o_doms'] = "Illimité"; }
				$tpl->assign(array(
					'c_doms' => $infos_heberg['c_doms'],
					'o_doms' => $infos_heberg['o_doms']
				));
		}
		else { header("Location:/panel/hebergement.html?id=".intval($_GET['id'])); }
	}
}
else { header("Location:/site/connexion.html"); }

?>